home *** CD-ROM | disk | FTP | other *** search
- #include <iostream.h>
- #include <fcntl.h>
- #include <sys\stat.h>
- #include <io.h>
- #include <stdlib.h>
-
- // send stdout to a file
- class Redirector
- {
- private :
- int fout; // handle for file
- int oldstdout; // handle for old stdout
- int onoff; // indicator that it has been redirected
-
- public :
- Redirector(void) { fout = 1; oldstdout = 0; onoff = 0; }
- Redirector(char *fid) { fout = 1; oldstdout = 0; onoff = 0; rdopen(fid); }
- ~ Redirector(void) { if (onoff == 1) rdclose(); }
- void rdopen(char *fid = "stdout.dat");
- void rdclose(void);
-
- };
-
-